import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    // 左边原始图片列表
    leftImgList: [],
    // 右边原始图片列表
    rightImgList: [],

  },
  mutations: {
    GETLEFTIMG(state, list) {
      // 避免重复插入列表
      if (state.leftImgList.indexOf(list) == -1) {
        state.leftImgList.push(list)
      }
    },
    GETRIGHTIMG(state, list) {
      // 避免重复插入列表
      if (state.rightImgList.indexOf(list) == -1) {
        state.rightImgList.push(list)
      }
    },
  },
  actions: {
    // 获取左边原始图片
    getLeftImg({ commit }) {
      commit('GETLEFTIMG', "https://via.placeholder.com/175x200?text=Picture1")
      commit('GETLEFTIMG', "https://via.placeholder.com/175x300?text=Picture2")
      commit('GETLEFTIMG', "https://via.placeholder.com/175?text=Picture3")
    },
    // 获取右边原始图片
    getRightImg({ commit }) {
      commit('GETRIGHTIMG', "https://via.placeholder.com/175x250?text=Picture1")
      commit('GETRIGHTIMG', "https://via.placeholder.com/175x200?text=Picture2")
      commit('GETRIGHTIMG', "https://via.placeholder.com/175?text=Picture3")
    },
  },
  getters: {
  },
})
